/*
 * @Author: kenan
 * @Date: 2022-04-12 15:26:02
 * @LastEditors: Jason Chen
 * @LastEditTime: 2022-12-05 11:09:30
 * @FilePath: /changeDbPassword/server/initialize/plugin.go
 * @Description:
 *
 * Copyright (c) 2022 by kenanlu@leansoftx.com, All Rights Reserved.
 */
package initialize

import (

	//email "github.com/flipped-aurora/gva-plugins/email" // 在线仓库模式go

	//"github.com/flipped-aurora/gin-vue-admin/server/plugin/email" // 本地插件仓库地址模式

	db_plugin "github.com/flipped-aurora/gin-vue-admin/server/plugin/db"
	"github.com/flipped-aurora/gin-vue-admin/server/utils/plugin"
	"github.com/gin-gonic/gin"
)

func PluginInit(group *gin.RouterGroup, Plugin ...plugin.Plugin) {
	for i := range Plugin {
		PluginGroup := group.Group(Plugin[i].RouterPath())
		Plugin[i].Register(PluginGroup)
	}
}

func InstallPlugin(PublicGroup *gin.RouterGroup, PrivateGroup *gin.RouterGroup) {
	//  添加开放权限的插件 示例
	PluginInit(PublicGroup,
		db_plugin.ExamplePlugin, db_plugin.CreatePlugin())

	//  添加跟角色挂钩权限的插件 示例 本地示例模式于在线仓库模式注意上方的import 可以自行切换 效果相同
	/* PluginInit(PrivateGroup, email.CreateEmailPlug(
		global.GVA_CONFIG.Email.To,
		global.GVA_CONFIG.Email.From,
		global.GVA_CONFIG.Email.Host,
		global.GVA_CONFIG.Email.Secret,
		global.GVA_CONFIG.Email.Nickname,
		global.GVA_CONFIG.Email.Port,
		global.GVA_CONFIG.Email.IsSSL,
	)) */

	// TODO: 修改成动态注册插件
	PluginInit(PrivateGroup)

	//PluginInit(PrivateGroup, smartide.CreateSmartIDEPlugin())
}
